package top.hkyzf.study.leetcode.array;

import org.junit.Test;

/**
 * description: 
 * @author zhufeng
 * @date 2024/3/14 0014 11:35
 * @version V1.0
 */
public class 合并后数组中的最大元素_2789 {
    public long maxArrayValue(int[] nums) {
        long max = nums[nums.length - 1];
        for(int i = nums.length-2; i >= 0; i--) {
            if (nums[i] <= max) {
                max = nums[i] + max;
            } else {
                max = nums[i];
            }
        }
        return max;
    }

    @Test
    public void testMaxArrayValue () {
        int[] nums = {2,3,7,9,3};
        System.out.println(maxArrayValue(nums));
    }
}
